home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 27.7 KB | 1,007 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: BaseShp.cpp
- // Release Version: $ ODF 2 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- #ifndef CONSTANT_H
- #include "Constant.h"
- #endif
-
- #ifndef DEFINES_K
- #include "Defines.k"
- #endif
-
- #ifndef DRAWCONT_H
- #include "DrawCont.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWFRM_H
- #include "DrawFrm.h"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWLINK_H
- #include "DrawLink.h"
- #endif
-
- #ifndef DRAWCLIP_H
- #include "DrawClip.h"
- #endif
-
- // ----- Part Layer -----
-
- #ifndef FWAPLEVT_H
- #include "FWAplEvt.h"
- #endif
-
- #ifndef FWFRMING_H
- #include "FWFrming.h"
- #endif
-
- #ifndef FWUTIL_H
- #include "FWUtil.h"
- #endif
-
- #ifndef FWSELECT_H
- #include "FWSelect.h"
- #endif
-
- #ifndef FWITERS_H
- #include "FWIters.h"
- #endif
-
- #ifndef FWINTER_H
- #include "FWInter.h"
- #endif
-
- #ifndef FWPRMISE_H
- #include "FWPrmise.h"
- #endif
-
- #ifndef FWDSCOPR_H
- #include "FWDscOpr.h"
- #endif
-
- #ifndef FWSEMTRM_H
- #include "FWSemTrm.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWACQUIR_H
- #include "FWAcquir.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWRECSHP_H
- #include "FWRecShp.h"
- #endif
-
- #ifndef FWTXTBOX_H
- #include "FWTxtBox.h"
- #endif
-
- #ifndef FWLINSHP_H
- #include "FWLinShp.h"
- #endif
-
- #ifndef FWOVLSHP_H
- #include "FWOvlShp.h"
- #endif
-
- #ifndef FWRRCSHP_H
- #include "FWRRcShp.h"
- #endif
-
- #ifndef FWODGEOM_H
- #include "FWODGeom.h"
- #endif
-
- #ifndef FWCFMRES_H
- #include "FWCFMRes.h"
- #endif
-
- #ifndef FWRESACC_H
- #include "FWResAcc.h"
- #endif
-
- #ifndef FWRESTYP_H
- #include "FWResTyp.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWSOMENV_H
- #include "FWSOMEnv.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODTransform_xh
- #include <Trnsform.xh>
- #endif
-
- //========================================================================================
- // Runtime Information
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdrawshapes
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- FW_DEFINE_AUTO(CBaseShape)
- FW_DEFINE_CLASS_M1(CBaseShape, FW_MScriptable)
-
- const FW_ClassTypeConstant LBaseShape = FW_TYPE_CONSTANT('s','h','b','a');
- FW_REGISTER_ARCHIVABLE_CLASS(LBaseShape, CBaseShape, CBaseShape::Read, 0, 0, CBaseShape::Write)
-
- //========================================================================================
- // globals
- //========================================================================================
-
- FW_CRectShape* CBaseShape::gWorkingHandle = NULL;
- unsigned long CBaseShape::gShapeCount = 0;
-
- // [KVV] Constructing gDefaultStyle and gDefaultInk like this causes
- // problems because of order of initialization
- // const FW_CStyle gDefaultStyle = FW_kNormalStyle;
- // const FW_CInk gDefaultInk = FW_kNormalInk;
-
- const FW_EStandardStyles gDefaultStyle = FW_kNormalStyle;
- const FW_EStandardInks gDefaultInk = FW_kNormalInk;
-
- //========================================================================================
- // class CShapeCollection
- //========================================================================================
-
- FW_DEFINE_AUTO(CShapeCollection)
-
- //========================================================================================
- // class CShapeCollectionIterator
- //========================================================================================
-
- FW_DEFINE_AUTO(CShapeCollectionIterator)
-
- //========================================================================================
- // class CBaseShape
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::CBaseShape(CDrawPart* drawPart,
- short numberOfHandles,
- unsigned short shapeType,
- unsigned short renderVerb) :
- FW_MScriptable(),
- fDrawPart(drawPart),
- fSelected(FALSE),
- fNumberOfHandles(numberOfHandles),
- fShapeType(shapeType),
- fPublishLink(NULL),
- fSubscribeLink(NULL),
- fRenderVerb(renderVerb),
- fFrameInk(gDefaultInk),
- fFillInk(gDefaultInk),
- fFrameStyle(gDefaultStyle),
- fFillStyle(gDefaultStyle),
- fPromised(0),
- fExternalizationIndex(0),
- fClipShape(NULL)
- {
- InitStatic();
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::CBaseShape(CDrawPart* drawPart, FW_CReadableStream& archive) :
- FW_MScriptable(),
- fDrawPart(drawPart),
- fPublishLink(NULL),
- fSubscribeLink(NULL),
- fSelected(FALSE),
- fPromised(0),
- fExternalizationIndex(0),
- fClipShape(NULL)
- {
- InitStatic();
-
- archive >> fShapeType;
- archive >> fNumberOfHandles;
-
- archive >> fFrameInk;
- archive >> fFillInk;
- archive >> fFrameStyle;
- archive >> fFillStyle;
-
- archive >> fRenderVerb;
- FW_END_CONSTRUCTOR
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::InitStatic
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::InitStatic()
- {
- if (gShapeCount == 0)
- {
- CBaseShape::gWorkingHandle = FW_NEW(FW_CRectShape, (FW_kZeroRect, FW_kFill));
- CBaseShape::gWorkingHandle->SetInk(FW_kInvertInk);
- }
-
- CBaseShape::gShapeCount++;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::~CBaseShape
- //----------------------------------------------------------------------------------------
-
- CBaseShape::~CBaseShape()
- {
- FW_START_DESTRUCTOR
- FW_ASSERT(fPromised == 0); // I should have resolved all my promises
-
- if (fClipShape)
- {
- FW_SOMEnvironment ev;
- fClipShape->Release(ev);
- }
-
- CBaseShape::gShapeCount--;
- if (CBaseShape::gShapeCount == 0)
- delete CBaseShape::gWorkingHandle;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Removed
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Removed(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Deleted
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Deleted(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CheckPromise
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::CheckPromise(Environment* ev)
- {
-
- if (fPromised & FW_kClipboardStorage)
- fDrawPart->GetDataInterchange(ev)->ResolveClipboardPromise(ev);
- FW_ASSERT((fPromised & FW_kClipboardStorage) == 0); // because CBaseShape::Promised should have been called
-
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Promised
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Promised(FW_StorageKinds storageKind, FW_Boolean state)
- {
- if (state)
- fPromised |= storageKind;
- else
- fPromised ^= fPromised & storageKind;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::TrackFeedback
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::TrackFeedback(Environment* ev,
- ODFacet* facet,
- FW_CGraphicContext& gc,
- const FW_CPoint& anchorPoint,
- const FW_CPoint& currentPoint,
- FW_Boolean erase)
- {
- if (!erase)
- SetShapeGeometry(anchorPoint, currentPoint);
-
- RenderShape(ev, facet, gc);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SelectShape
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SelectShape(Environment* ev, FW_Boolean state)
- {
- FW_UNUSED(ev);
- fSelected = state;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ClearCache
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ClearCache(Environment* ev)
- {
- if (fClipShape)
- {
- fClipShape->Release(ev);
- fClipShape = NULL;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Invalidate
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Invalidate(Environment* ev)
- {
- fDrawPart->GetDrawContent()->RedrawShape(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::RenderHandles
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::RenderHandles(FW_CGraphicContext& gc, FW_Fixed zoomFactor)
- {
- FW_Fixed penSize = CalcHandlePenSize(zoomFactor);
- for (short i=1; i<=fNumberOfHandles; i++)
- {
- CalcHandle(i, CBaseShape::gWorkingHandle, penSize);
- CBaseShape::gWorkingHandle->Render(gc);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::InvalidateHandles
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::InvalidateHandles(Environment* ev, FW_CView* contentView, ODShape* workingShape, FW_Fixed penSize)
- {
- FW_CRect rect;
- for (short i=1; i<=fNumberOfHandles; i++)
- {
- CalcHandle(i, rect, penSize);
- workingShape->SetRectangle(ev, rect);
- contentView->Invalidate(ev, workingShape);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CalcHandle
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::CalcHandle(short whichHandle, FW_CRectShape* handle, FW_Fixed penSize) const
- {
- FW_CRect rect;
- CalcHandle(whichHandle, rect, penSize);
- handle->SetRectangle(rect);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::CalcHandle
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::CalcHandle(short whichHandle, FW_CRect& rect, FW_Fixed penSize) const
- {
- FW_CPoint pt;
- GetHandleCenter(whichHandle, pt);
- rect.Set(pt.x - penSize, pt.y - penSize, pt.x + penSize, pt.y + penSize);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::InSelectionRect
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::InSelectionRect(const FW_CRect& selectRect) const
- {
- FW_CRect bounds = GetRectGeometry();
-
- FW_CRect temp(bounds);
- temp.Intersection(selectRect);
-
- return bounds == temp;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Flatten
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Flatten(FW_CWritableStream& archive)
- {
- archive << fShapeType;
- archive << fNumberOfHandles;
-
- archive << fFrameInk;
- archive << fFillInk;
- archive << fFrameStyle;
- archive << fFillStyle;
-
- archive << fRenderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedAfter
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedAfter(Environment* ev, CBaseShape* shape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(shape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedBefore
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedBefore(Environment* ev, CBaseShape* shape)
- {
- FW_UNUSED(ev);
- FW_UNUSED(shape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedFirst
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedFirst(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MovedLast
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MovedLast(Environment* ev)
- {
- FW_UNUSED(ev);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::RestoreShape
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::RestoreShape(Environment *ev)
- {
- if(fShapeType == kGroupShape || fSubscribeLink == NULL)
- fDrawPart->AddShapeToPart(ev, this);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetFrozen
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::SetFrozen(FW_Boolean state)
- {
- FW_UNUSED(state);
- return FALSE; // Means I don't care
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::IsFrozen
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::IsFrozen() const
- {
- return FALSE;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetPenSize
- //----------------------------------------------------------------------------------------
-
- FW_Fixed CBaseShape::GetPenSize() const
- {
- return HasFrameStyle() ? fFrameStyle.GetPenSize() : FW_kFixed0;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetColor
- //----------------------------------------------------------------------------------------
- void CBaseShape::GetColor(FW_Boolean fill, FW_CColor& color)
- {
- if (fill)
- fFillInk.GetForeColor(color);
- else
- fFrameInk.GetForeColor(color);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetPattern
- //----------------------------------------------------------------------------------------
- FW_CPattern CBaseShape::GetPattern(FW_Boolean fill)
- {
- if (fill)
- return fFillStyle.GetPattern();
- else
- return fFrameStyle.GetPattern();
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::UnshareInk
- //----------------------------------------------------------------------------------------
-
- FW_CInk CBaseShape::UnshareInk(const FW_CInk& ink) const
- {
- // Do not use the following syntax. It looks like the life time of temporaries
- // is wrong causing a bad refcounting problem
- // return (ink->GetRefCount() > 1) ? ink->Copy() : ink;
-
- if (ink.GetRefCount() > 1)
- return ink.Copy();
- else
- return ink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::UnshareStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle CBaseShape::UnshareStyle(const FW_CStyle& style) const
- {
- // Do not use the following syntax. It looks like the life time of temporaries
- // is wrong causing a bad refcounting problem
- // return (style->GetRefCount() > 1) ? style->Copy() : style;
-
- if (style.GetRefCount() > 1)
- return style.Copy();
- else
- return style;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFrameColor
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFrameColor(Environment* ev, const FW_CColor& color)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev);
-
- fFrameInk = UnshareInk(fFrameInk);
- fFrameInk.SetForeColor(color);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFramePattern
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFramePattern(Environment* ev, const FW_CPattern& pattern)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev);
-
- fFrameStyle = UnshareStyle(fFrameStyle);
- fFrameStyle.SetPattern(pattern);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFillColor
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFillColor(Environment* ev, const FW_CColor& color)
- {
- if (HasFillStyle())
- {
- CheckPromise(ev);
-
- fFillInk = UnshareInk(fFillInk);
- fFillInk.SetForeColor(color);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeFillPattern
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeFillPattern(Environment* ev, const FW_CPattern& pattern)
- {
- if (HasFillStyle())
- {
- CheckPromise(ev);
-
- fFillStyle = UnshareStyle(fFillStyle);
- fFillStyle.SetPattern(pattern);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangePenSize
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangePenSize(Environment* ev, FW_Fixed newPenSize)
- {
- if (HasFrameStyle())
- {
- CheckPromise(ev);
-
- ClearCache(ev);
-
- fFrameStyle = UnshareStyle(fFrameStyle);
- fFrameStyle.SetPenSize(newPenSize);
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetSubscribeLink
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetSubscribeLink(Environment* ev, CDrawSubscribeLink *subscribeLink)
- {
- FW_UNUSED(ev);
-
- fSubscribeLink = subscribeLink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetPublishLink
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetPublishLink(Environment* ev, CDrawPublishLink *publishLink)
- {
- FW_UNUSED(ev);
-
- fPublishLink = publishLink;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::AdjustRectForPenSize
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::AdjustRectForPenSize(FW_CRect& rect, FW_Fixed penSize) const
- {
- FW_Fixed half = FW_Half(penSize);
- rect.Inset(-half, -half);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::ChangeRenderVerb
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::ChangeRenderVerb(Environment* ev, unsigned short renderVerb)
- {
- CheckPromise(ev);
-
- ClearCache(ev);
- fRenderVerb = renderVerb;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetObjectClass
- //----------------------------------------------------------------------------------------
-
- ODDescType CBaseShape::GetObjectClass() const
- {
- return kShapeClass;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::HasProperty
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::HasProperty(ODDescType whichProperty) const
- {
- FW_Boolean hasProperty;
-
- switch (whichProperty)
- {
- case pColor:
- case pPosition:
- case pIndex:
- hasProperty = TRUE;
- break;
-
- default:
- hasProperty = FW_MScriptable::HasProperty(whichProperty);
- break;
- }
- return hasProperty;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetProperty
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::GetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty,
- ODDescType desiredType) const
- {
- FW_Boolean result = TRUE;
-
- switch (whichProperty)
- {
- case pColor:
- {
- FW_CColor color = fFillInk.GetForeColor();
- propertyValue << color;
- }
- break;
-
- case pPosition:
- propertyValue << GetRectGeometry().TopLeft().AsPlatformPoint();
- break;
-
- default:
- result = FW_MScriptable::GetProperty(ev, part, propertyValue, whichProperty, desiredType);
- break;
- }
-
- return result;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SetProperty
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::SetProperty(Environment* ev,
- FW_CPart* part,
- FW_CDesc& propertyValue,
- ODDescType whichProperty)
- {
- switch (whichProperty)
- {
- case pColor:
- {
- if (HasFillStyle())
- {
- FW_CColor newColor;
- propertyValue >> newColor;
-
- FW_CColor oldColor;
- GetColor(TRUE, oldColor);
-
- if (newColor != oldColor)
- {
- ChangeFillColor(ev, newColor);
- Invalidate(ev);
- }
- }
- }
- break;
-
- case pPosition:
- {
- FW_CPoint newPosition;
- FW_CRect bounds = GetRectGeometry();
-
- propertyValue >> newPosition;
-
- Invalidate(ev); // inval the old location
- OffsetShape(ev, newPosition.x - bounds.left, newPosition.y - bounds.top);
- Invalidate(ev); // inval the new location
- }
- break;
-
- default:
- FW_MScriptable::SetProperty(ev, part, propertyValue, whichProperty);
- break;
- }
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUndoStrings
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUndoStrings(Environment* ev,
- FW_CPart* part,
- ODDescType whichProperty,
- FW_CString& undoString,
- FW_CString& redoString) const
- {
- if (whichProperty == pColor)
- {
- FW_PSharedLibraryResourceFile resFile(ev);
- ::FW_LoadStringByID(ev, resFile, kDrawUndoStrings, FW_kMultiStringRes, kUndoFillColorMsg, undoString);
- ::FW_LoadStringByID(ev, resFile, kDrawUndoStrings, FW_kMultiStringRes, kRedoFillColorMsg, redoString);
- }
- else
- FW_MScriptable::GetUndoStrings(ev, part, whichProperty, undoString, redoString);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Read
- //----------------------------------------------------------------------------------------
-
- void* CBaseShape::Read(FW_CReadableStream& stream, FW_ClassTypeConstant type)
- {
- FW_UNUSED(stream);
- FW_UNUSED(type);
- FW_DEBUG_MESSAGE("CBaseShape::Read should never be called");
- return NULL;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::Write
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::Write(FW_CWritableStream& stream, FW_ClassTypeConstant type, const void *object)
- {
- FW_UNUSED(type);
- ((CBaseShape*)object)->Flatten(stream);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUpdateBox
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUpdateBox(Environment* ev, ODShape* updateBox) const
- {
- FW_CRect bounds = GetRectGeometry();
-
- const FW_Fixed fxMargin = FW_IntToFixed(3);
-
- bounds.left -= fxMargin;
- bounds.top -= fxMargin;
- bounds.right += fxMargin;
- bounds.bottom += fxMargin;
-
- ODRect odBounds = bounds;
- updateBox->SetRectangle(ev, &odBounds);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetUpdateBox
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetUpdateBox(FW_CRect& updateBox) const
- {
- updateBox = GetRectGeometry();
-
- const FW_Fixed fxMargin = FW_IntToFixed(3);
-
- updateBox.left -= fxMargin;
- updateBox.top -= fxMargin;
- updateBox.right += fxMargin;
- updateBox.bottom += fxMargin;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetDragRect
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::GetDragRect(FW_CRect& dragRect) const
- {
- dragRect = GetRectGeometry();
- AdjustRectForPenSize(dragRect, GetPenSize());
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::GetResizeStyle
- //----------------------------------------------------------------------------------------
-
- FW_CStyle CBaseShape::GetResizeStyle() const
- {
- FW_CStyle resizeStyle(GetPenSize(), FW_kGrayPat);
- return resizeStyle;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::SubtractToWorkingClip
- //----------------------------------------------------------------------------------------
- // ATTENTION: workingClip is in Content coordinates. tempShape is just a working shape. It is
- // allocated by CDrawFrame::ClipEmbeddedFacets so I don't have to allocate one everytime.
-
- void CBaseShape::SubtractToWorkingClip(Environment *ev,
- CDrawFacetClipper* facetClipper,
- ODFacet* containingFacet,
- ODShape* workingClip,
- ODShape* tempShape,
- ODShape* limitShape)
- {
- FW_UNUSED(facetClipper);
- FW_UNUSED(containingFacet);
- FW_UNUSED(tempShape);
- FW_UNUSED(limitShape);
-
- FW_CAcquiredODShape clipShape = AcquireClipShape(ev);
- workingClip->Subtract(ev, clipShape);
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::WhichHandle
- //----------------------------------------------------------------------------------------
-
- short CBaseShape::WhichHandle(FW_CGraphicContext& gc, const FW_CPoint& mouse, FW_Fixed zoomFactor) const
- {
- FW_Fixed penSize = CalcHandlePenSize(zoomFactor);
- for (short i=1; i<=fNumberOfHandles; i++)
- {
- CalcHandle(i, CBaseShape::gWorkingHandle, penSize);
- if (CBaseShape::gWorkingHandle->HitTest(gc, mouse, FW_kFixed0))
- return i;
- }
-
- return 0;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::IsInLinkDestination
- //----------------------------------------------------------------------------------------
-
- FW_Boolean CBaseShape::IsInLinkDestination(Environment* ev)
- {
- FW_UNUSED(ev);
- return IsSubscribed();
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::AcquireClipShape
- //----------------------------------------------------------------------------------------
-
- ODShape* CBaseShape::AcquireClipShape(Environment* ev)
- {
- if (fClipShape == NULL)
- fClipShape = CalcClipShape(ev);
-
- fClipShape->Acquire(ev);
- return fClipShape;
- }
-
- //----------------------------------------------------------------------------------------
- // CBaseShape::MakePurgeable
- //----------------------------------------------------------------------------------------
-
- void CBaseShape::MakePurgeable(Environment* ev, CDrawFrame* drawFrame, const FW_CRect& bounds)
- {
- FW_UNUSED(ev);
- FW_UNUSED(drawFrame);
- FW_UNUSED(bounds);
- // Does nothing (see CProxyShape::MakePurgeable)
- }
-